/**
 * All rights Reserved, Designed By 信鸥科技
 * project : committee
 * Created by youquer on 17/10/31.
 * 注意：本内容仅限于信鸥科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 * Description:
 *
 */

//React+dva 基础
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';

//css样式
import styles from './Pwd.less';
//组件
import { Form, Icon, Input, Button, Checkbox, Row, Col, Card } from 'antd';
const FormItem = Form.Item;
import AddInput from '@/components/common/AddInput';
import PageHeaderLayout from '@/layouts/PageHeaderLayout';

const Pwd =({pwd, dispatch})=>{

  const {type, newPwd, oldPwd, loading} = pwd;
  const data = pwd;

  const formItemLayout = {
    labelCol: {
      xs: { span: 24 },
      sm: { span: 4 },
    },
    wrapperCol: {
      xs: { span: 24 },
      sm: { span: 20 },
    },
  };

  const inputcolumns = [
    {
      title: "旧密码",
      type:"Input",
      //help: "sshelp",
      hasFeedback: true,
      placeholder: "",
      validateStatus: "",
      required: true,
      formItemLayout: {...formItemLayout},
      inputType: "password",

      key: 'oldPwd',
    },
    {
      title: "新密码",
      type:"Input",
      //help: "sshelp",
      hasFeedback: true,
      placeholder: "",
      validateStatus: "",
      required: true,
      formItemLayout: {...formItemLayout},
      inputType: "password",

      key: 'newPwd',
    }
  ];

  const param = {
    inputcolumns,
    type,
    data,
  };

  const update = {newPwd, oldPwd};
  function enterLoading(){
    dispatch({
      type: type + "/submit",
      loading:true
    });
    dispatch({
      type: type + '/changePwd',
      payload: update
    })
  }

  return(
    <PageHeaderLayout title="修改密码">
      <Card bordered={false}>
        <div className={styles.add_div}>
          <AddInput {...param} />
          <div className={styles.submit_div}>
            <Button type="primary" value={loading} onClick={enterLoading}>
              确定
            </Button>
          </div>
        </div>
      </Card>
    </PageHeaderLayout>
  )
};

export default connect(
  ({pwd}) => ({pwd})
)(Pwd);
